{% extends 'base.html' %} {% load staticfiles %} {% block title %}机房:{{ datacenter.name }}{% endblock %} {% block css %}

<!-- Theme style -->
<link rel="stylesheet" href="{% static 'dist/css/AdminLTE.min.css' %}">
<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="{% static 'dist/css/skins/_all-skins.min.css' %}"> {% endblock %} {% block content %}

<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
        机房详细
  </h1>
  <ol class="breadcrumb">
    <li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
    <li>机房管理</li>
    <li class="active">机房详细</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">

  <!-- Default box -->
  <div class="box">
    <div class="box-body">
      <div class="nav-tabs-custom">
        <ul class="nav nav-tabs">
          <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="false">基本信息</a></li>
          <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">机房管理单元</a></li>
          <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">更新日志</a></li>
        </ul>
        <div class="tab-content">
          <div class="tab-pane active" id="tab_1">
            <h4><b>概览:</b></h4>
            <div class="row">
              <div class="col-xs-2 text-right">机房名称:</div>
              <div class="col-xs-4">{{ datacenter.name }}</div>
              <div class="col-xs-2 text-right">机房简称:</div>
              <div class="col-xs-4">{{ datacenter.shortname }}</div>
            </div>
            <br>
            <div class="row">
              <div class="col-xs-2 text-right">机房运营商:</div>
              <div class="col-xs-4">{{ datacenter.isp }}</div>
              <div class="col-xs-2 text-right">机房维护人:</div>
              <div class="col-xs-4">{{ datacenter.admin|default:'' }}</div>
            </div>
            <br>
            <div class="row">
              <div class="col-xs-2 text-right">机房联系电话:</div>
              <div class="col-xs-4">{{ datacenter.contactnumber }}</div>
              <div class="col-xs-2 text-right">机房地址:</div>
              <div class="col-xs-4">{{ datacenter.address }}</div>
            </div>
            <br>
            <p style=" margin:0 auto; text-align:center;">
              <button class="btn btn-default " align="center"  data-toggle="modal" data-target="#datacentereditModal">修改</button>
            </p>
            <br>
            <h4><b>机柜:</b></h4>
            <table id="cabinet_table" border="1" class="display table table-bordered table-striped" >
              <thead>
                <tr>
                  <th>编号</th>
                  <th>机房管理单元</th>
                  <th>高度(U)</th>
                  <th>是否自用</th>
                  <th>是否开电</th>
                  <th>电力(A)</th>
                  <th>备注</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  {% for cabinet in cabinet %}
                  <td><a href="{% url 'cabinetdetail' cabinet.id %}" target=_blank>{{ cabinet.name }}</td>
                  <td>{{ cabinet.room }}</td>
                  <td>{{ cabinet.slotcount }}</td>
                  <td>{{ cabinet.get_user_display }}</td>
                  <td>{{ cabinet.get_status_display }}</td>
                  <td>{{ cabinet.power }}</td>
                  <td>{{ cabinet.memo }}</td>
                </tr>
                {% empty %}
                <tr>没有数据！</tr>
                {% endfor %}
              </tbody>
            </table>
            <form class="form-horizontal content_size" action="{% url 'datacenterdetail' datacenter.id %}" method="post">
              {% csrf_token %}
              <div class="modal fade" id='datacentereditModal' tabindex="-1" role="dialog" aria-labelledby='myModelLabel' aria-hidden="true">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                      <h4 class="modal-title">机房信息修改</h4>
                    </div>
                    <div class="modal-body">
                      <form class="form-horizontal" role="form">
                      <div class="form-group">
                        <label for="modify" class="col-sm-2 control-label">机房名称:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" type="text" value= {{ datacenter.name }} name='name'>
                        </div>
                        <label for="modify" class="col-sm-2 control-label">机房简称:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" value= {{ datacenter.shortname }} name='shortname'>
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="modify" class="col-sm-2 control-label">机房运营商:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" name='isp' value= {{ datacenter.isp }}>
                        </div>  
                        <label for="modify" class="col-sm-2 control-label">机房维护人:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" value= {{ datacenter.admin }} name='admin'>
                        </div>  
                      </div>
                      <div class="form-group">
                        <label for="modify" class="col-sm-2 control-label">机房联系电话:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" value= {{ datacenter.contactnumber }} name='contactnumber'>
                        </div>
                        <label for="modify" class="col-sm-2 control-label">机房地址:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" value= {{ datacenter.address }} name='address'>
                        </div>
                      </div>
                      <div class="form-group">  
                        <label for="modify" class="col-sm-2 control-label">备注:</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name='memo' value= {{ datacenter.memo }}>
                        </div>
                      </div>
                      <div class="form-group">    
                        <label for="modify" class="col-sm-2 control-label">修改原因:<font color='#ff0000'>*</font></label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name='reason' required>
                        </div>
                      </div>
                      </form>
                    </div>
                    <div class="modal-footer">
                      <button type="submit" name="submit" value="datacenter_edit" class="btn btn-primary">确认</button>
                      <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    </div>
                  </div>
                </div>
              </div>
            </form>
          </div>
          <!-- /.tab-pane tab_1 -->
          <div class="tab-pane" id="tab_2">
            <h4><b>机房管理单元:</b></h4>
            <table border="1" class="display table table-bordered table-striped" >
              <thead>
                <tr>
                  <th>管理单元名称</th>
                  <th>负责人</th>
                  <th>备注</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  {% for machineroom in machineroom %}
                  <td id='machineroom_name'>{{ machineroom.name }}</td>
                  <td id='machineroom_admin'>{{ machineroom.admin }}</td>
                  <td id='machineroom_memo'>{{ machineroom.memo }}</td>
                  <td>
                    <button type="button" class="btn btn-sm btn-info" onclick="machineroomedit(this)">修改</button>
                    <button type="button" class="btn btn-sm btn-danger" onclick="machineroomdel(this)">删除</button>
                  </td>
                </tr>
                {% empty %}
                <tr>没有数据！</tr>
                {% endfor %}
              </tbody>
            </table>
            <p style=" margin:0 auto; text-align:center;">
              <button class="btn btn-default " align="center"  data-toggle="modal" data-target="#machineroomAddModal">添加</button>
            </p>
            <br>
            <form class="form-horizontal content_size" action="{% url 'datacenterdetail' datacenter.id %}" method="post">
              {% csrf_token %}
              <div class="modal fade" id='machineroomAddModal' tabindex="-1" role="dialog" aria-labelledby='myModelLabel' aria-hidden="true">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                      <h4 class="modal-title">添加机房管理单元</h4>
                    </div>
                    <div class="modal-body">
                      <form class="form-horizontal" role="form">
                      <div class="form-group">
                        <label for="modify" class="col-sm-2 control-label">机房管理单元:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" type="text" name='name'>
                        </div>
                        <label for="modify" class="col-sm-2 control-label">维护人:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" name='admin'>
                        </div>
                      </div>
                      <div class="form-group">  
                        <label for="modify" class="col-sm-2 control-label">备注:</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name='memo'>
                        </div>
                      </div>
                      </form>
                    </div>
                    <div class="modal-footer">
                      <button type="submit" name="submit" value="machineroom_add" class="btn btn-primary">确认</button>
                      <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    </div>
                  </div>
                </div>
              </div>
            </form>
            <form class="form-horizontal content_size" action="{% url 'datacenterdetail' datacenter.id %}" method="post">
              {% csrf_token %}
              <div class="modal fade" id='machineroomEditModal' tabindex="-1" role="dialog" aria-labelledby='myModelLabel' aria-hidden="true">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                      <h4 class="modal-title">修改机房管理单元</h4>
                    </div>
                    <div class="modal-body">
                      <form class="form-horizontal" role="form">
                      <div class="form-group">
                        <label for="modify" class="col-sm-2 control-label">机房管理单元:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" type="text" name='name' readonly id='machineroom_nametext'>
                        </div>
                        <label for="modify" class="col-sm-2 control-label">维护人:</label>
                        <div class="col-sm-3">
                          <input type="text" class="form-control" name='admin' id='machineroom_admintext'>
                        </div>
                      </div>
                      <div class="form-group">  
                        <label for="modify" class="col-sm-2 control-label">备注:</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name='memo' id='machineroom_memotext'>
                        </div>
                      </div>
                      <div class="form-group">
                        <label for="modify" class="col-sm-2 control-label">修改原因:<font color='#ff0000'>*</font></label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name='reason' required>
                        </div>
                      </div>
                      </form>
                    </div>
                    <div class="modal-footer">
                      <button type="submit" name="submit" value="machineroom_edit" class="btn btn-primary">确认</button>
                      <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    </div>
                  </div>
                </div>
              </div>
            </form>
            <form class="form-horizontal content_size" action="{% url 'datacenterdetail' datacenter.id %}" method="post">
              {% csrf_token %}
              <div class="modal fade" id='machineroomDelModal' tabindex="-1" role="dialog" aria-labelledby='myModelLabel' aria-hidden="true">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                      <h4 class="modal-title">删除机房管理单元</h4>
                    </div>
                    <div class="modal-body">
                      <form class="form-horizontal" role="form">
                      <div class="form-group">
                        <label for="modify" class="col-sm-2 control-label">机房管理单元:</label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name='name' readonly id='delmachineroom_nametext'>
                        </div>
                      </div>
                      <div class="form-group">  
                        <label for="modify" class="col-sm-2 control-label">删除原因:<font color='#ff0000'>*</font></label>
                        <div class="col-sm-8">
                          <input type="text" class="form-control" name='reason' required>
                        </div>
                      </div>
                      </form>
                    </div>
                    <div class="modal-footer">
                      <button type="submit" name="submit" value="machineroom_del" class="btn btn-primary">确认</button>
                      <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    </div>
                  </div>
                </div>
              </div>
            </form>
          
          </div>
          <!-- /.tab-pane tab_2 -->
          <div class="tab-pane" id="tab_3">
        <h4><b>{{ asset.name }} 日志信息:</b></h4>
          <table id="eventlog_table" border="1" class="display table table-bordered table-striped">
            <thead>
              <tr>
                  <th>类型</th>
                  <th>详细内容</th>
                  <th>操作原因</th>
                  <th>操作时间</th>
                  <th>操作人</th>
              </tr>
            </thead>
            <tbody>
              {% for log in eventlog %}
              <tr>
                <td id="log_event_type">{{ log.get_event_type_display }}</td>
                <td id="log_detail">{{ log.detail }}</td>
                <td id="log_reason">{{ log.reason }}</td>
                <td id="log_date">{{ log.date|date:"Y-m-d  H:i:s" }}</td>
                <td id="log_user">{{ log.user }}</td>
              </tr>
              {% empty %}
              <tr>没有日志信息！</tr>
              {% endfor %}
            </tbody>
        </table>
          </div>
          <!-- /.tab-pane tab_3 -->
        </div>
      </div>
    </div>
    <!-- /.box-body -->
    <div class="box-footer">
      <i class="fa fa-angle-double-left"></i>&nbsp;&nbsp;<a href="{% url 'index' %}"><strong>返回资产列表页</strong></a>
    </div>
    <!-- /.box-footer-->
  </div>
  <!-- /.box -->
</section>
<!-- /.content -->

<script>
  function machineroomedit(obj) {
    var tr = $(obj).parent().parent();
    var machineroom_name = tr.children("td#machineroom_name").text();
    var machineroom_admin = tr.children("td#machineroom_admin").text();
    var machineroom_memo = tr.children("td#machineroom_memo").text();
    $('#machineroom_nametext').val(machineroom_name);
    $('#machineroom_admintext').val(machineroom_admin);
    $('#machineroom_memotext').val(machineroom_memo);
    $('#machineroomEditModal').modal('show');
  };

  function machineroomdel(obj) {
    var tr = $(obj).parent().parent();
    var machineroom_name = tr.children("td#machineroom_name").text();
    $('#delmachineroom_nametext').val(machineroom_name);
    $('#machineroomDelModal').modal('show');
  };
</script>
{% endblock %}
